package com.csx.saas.platform.system.controller;

import com.csx.basic.base.R;
import com.csx.basic.base.controller.SuperCacheController;
import com.csx.saas.platform.system.dto.SystemUserPageQuery;
import com.csx.saas.platform.system.dto.SystemUserSaveDTO;
import com.csx.saas.platform.system.dto.SystemUserUpdateDTO;
import com.csx.saas.platform.system.entity.SystemUser;
import com.csx.saas.platform.system.service.SystemUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * <p>
 * 前端控制器
 * 平台用户
 * </p>
 *
 * @author ChenSongXin
 * @date 2021-02-28
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/systemUser")
@Api(value = "SystemUser", tags = "平台用户")
//@PreAuth(replace = "platform:systemUser:")
public class SystemUserController extends SuperCacheController<SystemUserService, Long, SystemUser, SystemUserPageQuery, SystemUserSaveDTO, SystemUserUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SystemUser> systemUserList = list.stream().map((map) -> {
            SystemUser systemUser = SystemUser.builder().build();
            //TODO 请在这里完成转换
            return systemUser;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(systemUserList));
    }
}
